﻿// -----------------------------------------------------------------------
// <copyright file="AuthorizeAdminAttribute.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Website.CustomAttributes
{
	#region Usings

	using System.Web;
	using System.Web.Mvc;

	#endregion

	/// <summary>
	/// Represents the admin authorization attribute.
	/// </summary>
	public class AuthorizeAdminAttribute : AuthorizeAttribute
	{
		/// <summary>
		/// Provides entry point to custom authorization check.
		/// </summary>
		/// <param name="httpContext">The individual http information about request.</param>
		/// <returns>The result of the authorization process.</returns>
		protected override bool AuthorizeCore(HttpContextBase httpContext)
		{
			bool isAdmin = false;

			if (httpContext.Session != null)
			{
				isAdmin = (bool)httpContext.Session["isAdmin"];
			}

			return isAdmin;
		}
	}
}